/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.elcom.emocbc.cbcresponseparser.cbcresponse.getmessagestatus;

import com.elcom.emocbc.cbcresponseparser.cbcresponse.structure.CbcMessage;
import com.thoughtworks.xstream.XStream;

/**
 *
 * @author GiangLT
 */
public class GetMessageStatusResponseParser {

    private XStream xStream;

    public GetMessageStatusResponseParser() {
        xStream = new XStream();
        xStream.alias("cbcResponse", GetMessageStatusResponse.class);
        xStream.useAttributeFor(ReturnValue.class, "type");
        xStream.alias("cbcMessageStatusResult", CbcMessageStatusResult.class);
        xStream.addImplicitCollection(ReturnValue.class, "cbcMessageStatusResults");
        xStream.useAttributeFor(CbcMessageStatusResult.class, "type");
        xStream.alias("cbcMessageStatusPerBsc", CbcMessageStatusPerBsc.class);
        xStream.addImplicitCollection(StatusPerBsc.class, "cbcMessageStatusPerBscs");
        xStream.alias("broadcastInformation", BroadcastInformation.class);
        xStream.addImplicitCollection(NumberOfBroadcastCompleteList.class, "broadcastInformations");
        xStream.addImplicitCollection(CbcMessageStatusPerBsc.class, "broadcastInformations");
    }

    public String marshall(GetMessageStatusResponse cbcResponse) {
        return xStream.toXML(cbcResponse);
    }

    public GetMessageStatusResponse unmarshall(String xmlResponse) {
        return (GetMessageStatusResponse) xStream.fromXML(xmlResponse);
    }
}
